<?php
/*Problem Domain
  To test the UserSession entity relation of TMS 
 */
include_once '../User.php';
include_once '../TrainingSession.php';
include_once '../UserSession.php';

class TestUserSession extends PHPUnit_Framework_TestCase
{
	public function testUserSessionObject()
	{
		$usr1 = new User("mohsin.sayyed@springcomputing.in", "******", "trainee"); 
		$usr3 = new User("abhijeet.majgaonkar@springcomputing.in", "******", "trainee");

		$sess1 = new TrainingSession("phpsession", "ketul", date("2015-02-08 11:14:15.638276"), TrainingSession::AVAILABLE, 'arrays,functions');
		$sess2 = new TrainingSession("webuisession", "piyush", date("2015-01-01 10:00:00"), TrainingSession::AVAILABLE);

		$us1 = new UserSession($usr1->getId(), $sess1->getId(), UserSession::PENDING); //initialy admin has assigned mohsin for php session
		$us3 = new UserSession($usr1->getId(), $sess2->getId(), UserSession::PENDING); //initialy admin has assigned mohsin for webui
                $this->assertEquals(UserSession::PENDING, $us1->getStatus());
		$us3->setStatus(UserSession::REJECTED); //mohsin has accepted the assigned session
		$us3->setReason('sorry a lot of php assignments to complete');

		$this->assertEquals(UserSession::REJECTED, $us3->getStatus());
		$this->assertEquals('sorry a lot of php assignments to complete', $us3->getReason());

		$us2 = new UserSession($usr3->getId(), $sess2->getId(), UserSession::PENDING);//initialy admin has assigned abhijeet for webui 
		$us2->setStatus(UserSession::ACCEPTED); //Abhijeet has accepted the assigned session
		$this->assertEquals(UserSession::ACCEPTED , $us2->getStatus());

		$sess2->setStatus(TrainingSession::POSTPONED);       //webui session is postponed to
		$sess2->setPostDateTime(date("2015-01-08 10:00:00")); // date : 2015-01-08 at 10:00:00

		$us2->setStatus(UserSession::REJECTED);
		$us2->setReason('sorry i am on leave on 2015-01-08');

		$this->assertEquals(UserSession::REJECTED, $us2->getStatus());

	}
}
?>
